<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.staticfile.net/jquery/3.7.1/jquery.min.js"></script>
  </head>
  <body>
    <button id="getButton">点击发送get请求</button>
    <button id="postButton">点击发送post请求</button>
    <button id="deleteButton">点击发送delete请求</button>
    <script>
      $(function () {
        $("#getButton").on("click", function () {
          console.log("发送get请求");
          $.ajax({
            type: "GET",
            url: "http://127.0.0.1:8000/api/get",
            data: { name: "zs", age: 18 },
            success: function (res) {
              console.log(res);
            },
          });
        });
        $("#postButton").on("click", function () {
          $.ajax({
            type: "POST",
            url: "http://127.0.0.1:8000/api/post",
            data: { name: "XSA", age: 22 },
            success: function (res) {
              console.log(res);
            },
          });
        });
        $("#deleteButton").on("click", function () {
          $.ajax({
            type: "DELETE",
            url: "http://127.0.0.1:8000/api/delete",
            data: { name: "XSA", age: 22 },
            success: function (res) {
              console.log(res);
            },
          });
        });
      });
    </script>
  </body>
</html>
